// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1

ItemChangeParent {
    id: root;
    height: (rectTotal.height > 0 ? rectTotal.y + rectTotal.height +  rectTotal.border.width * 2 : rectTotal.y + rectCabecalho.height + rectTotal.border.width * 2);
    parentToPut: defaultParentComponent.createObject(rectTotal)
    ignores: ["rectTotal", "rectCabecalho", "containerPadrao"]

    property string titulo : ""
    property color corBorda : "red"
    property color corFundo: "black"
    property color corTexto: "white"
    property int tamanhoTextoTitulo: 20

    Component {
        id: defaultParentComponent

        Column {
            id: colPai
            anchors { left: parent.left; top: parent.top; right: parent.right; margins: 10; topMargin: 30 }
        }
    }

    Rectangle {
        id: rectTotal
        width: parent.width; height: (rectTotal.children.length == 1 ? rectTotal.children[0].height + rectTotal.children[0].anchors.topMargin + rectTotal.children[0].anchors.bottomMargin  : 0)
        x: 5; y: 10;
        border { width: 1; color: root.corBorda }
        color: root.corFundo
        objectName: "rectTotal"        
    }

    Rectangle {
        id: rectCabecalho
        x: 10; y: 5;
        width: childrenRect.width + 10; height: childrenRect.height
        border { width: 1; color: root.corBorda }
        color: root.corFundo
        objectName: "rectCabecalho"

        Text {
            id: txtTitulo
            text: root.titulo
            color: root.corTexto
            font { pixelSize: root.tamanhoTextoTitulo; bold: true }
            x: 5
        }
    }
}
